<?php

namespace App\Services\SpiderContent;

use Carbon\Carbon;
use App\Models\User;
use App\Models\Blogger;
use App\Models\Video;
use App\Jobs\RewardFirstParentJob;
use Illuminate\Support\Facades\Log;
use Rainsens\Dinglog\Facades\Dinglog;
use Illuminate\Database\Eloquent\Collection;
use Sunra\PhpSimple\HtmlDomParser;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Nesk\Puphpeteer\Puppeteer;
use Illuminate\Http\Request;
use GuzzleHttp\Client;

use DOMDocument;


class DouyinVideo
{

	protected Video $video;

    public function __construct(Video $video)
    {
        $this->video = $video;
    }

    public function execute($url,$id)
    {



    	header('Access-Control-Allow-Origin:*');
		header("Content-Type:application/json;charset=utf-8");


		//$url="https://v.douyin.com/fz9mh7qCemo/";
		//$apiUrl = "https://api.pearktrue.cn/api/dy/dy_video.php?url=".$url;
		//$apiUrl = "https://api.pearktrue.cn/api/video/douyin/?url=".$url;

		$apiUrl = "https://api.pearktrue.cn/api/private/media/douyin_info/?url=".$url."&type=all&key=836190a26704ef00&page=1&maxsum=20";

		$videoList = $this->curl($apiUrl);
	

		$videoList = json_decode($videoList,true);


		if(isset($videoList['code']) && $videoList['code']=="200"){
			$aid = 0;
			foreach($videoList['data'] as $video){
				preg_match('/[0-9]+/', $video['link'], $aid);
		        $aid = $aid[0];
				$isVideoExists = Video::query()->where('bli_aid',$aid)->exists();

				if(!$isVideoExists){
					$insertData = [
	        			'bli_aid'=>$aid,
	        			'url'=>$video['link'],
	        			'blogger_id'=>$id,
	        			'like'=>$video['digg'],
	        			'collect'=>$video['collect'],
	        			'title'=>$video['title'],
	        		];
                    

                    $content = file_get_contents($video['video']);
                    $newFileName = "/video/".Str::random(40) . '.mp4'; // 默认MP4格式
                    Storage::disk('ossnew')->put($newFileName, $content);

                    $insertData['video_url'] = Storage::disk('ossnew')->path($newFileName);

	        		Video::create($insertData);
	        	}
				/*if(!$isVideoExists){

	        		$insertData = [
	        			'bli_aid'=>$aid,
	        			'url'=>$video['link'],
	        			'blogger_id'=>$id
	        		];

	        		// 构造请求数据
			        $header = array('User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/122.0.0.0');

			        // 发送请求获取视频信息
			        $response = $this->curl('https://www.iesdouyin.com/share/video/' . $aid, $header);
			        $pattern = '/window\._ROUTER_DATA\s*=\s*(.*?)\<\/script>/s';
			        preg_match($pattern, $response, $matches);

			        if (empty($matches[1])) {
			            return array('code' => 201, 'msg' => '解析失败');
			        }

			        $videoInfo = json_decode(trim($matches[1]), true);

			        
			        if (!isset($videoInfo['loaderData'])) {
			            return array('code' => 201, 'msg' => '解析失败');
			        }
			        //替换 "playwm" 为 "play"
			        $videoResUrl = str_replace('playwm', 'play', $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['video']['play_addr']['url_list'][0]);

			        $insertData['video_url']=$videoResUrl;
			        $insertData['like']=$videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['statistics']['digg_count'];
			        $insertData['title']=$videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['desc'];

	        		Video::create($insertData);

	        		sleep(3);
	        	}*/


			}
		}
		

      

        // 构造返回数据
      /*  $arr = array(
            'code' => 200,
            'msg' => '解析成功',
            'data' => array(
                'author' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['author']['nickname'],
                'uid' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['author']['unique_id'],
                'avatar' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['author']['avatar_medium']['url_list'][0],
                'like' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['statistics']['digg_count'],
                'time' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]["create_time"],
                'title' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['desc'],
                'cover' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['video']['cover']['url_list'][0],
                'url' => $videoResUrl,
                'music' => array(
                    'author' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['music']['author'],
                    'avatar' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['music']['cover_large']['url_list'][0]
                )
            )
        );*/

       /* dd($arr);
        return $arr;
 */
		
    }


    public function djNodes($nodes,$res)
    {
    	if($nodes->nextSibling && $nodes->nextSibling->nodeName!="h4"){

    		$res['content'] = $res['content'].$nodes->nextSibling->textContent;


    		if($nodes->nextSibling->childNodes){

    			foreach($nodes->nextSibling->childNodes as $nn){
    				if($nn->nodeName=="img"){
    					$res['image'] = $nn->getAttribute('src');
    				}
    			}
    		}
    		
    		if(isset($nodes->nextSibling->nextSibling)  && $nodes->nextSibling->nextSibling->nodeName != "h4"){

    			 $res = $this->djNodes($nodes->nextSibling,$res);
    		}
    	}

    	return  $res;
    	//dd($nodes->nextSibling->nextSibling);
    	

    }


  
	


	 function SendJsonPostData($jsonStr)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_URL, "http://172.28.157.79:8787/X-Bogus");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
            "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
            "Content-Type:application/json;charset=utf-8",
            "Connection: keep-alive"
        ]);
        curl_setopt($ch, CURLOPT_ENCODING, '');
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $result = curl_exec($ch);
        if (curl_errno($ch)) {
            $content = [
                'code' => 500,
                'msg' => "访问出错",
                'api_source' => "官方API网:https://api.pearktrue.cn/"
            ];
            print_json($content);
            exit();
        }
        curl_close($ch);
        return $result;
    }

    function SendGetData($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Postman/10.16.0 Chrome/100.0.4896.160 Electron/18.3.5 Safari/537.36");
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_HTTPHEADER, [
            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
            "Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
            "Referer: https://www.douyin.com/",
            "Connection: keep-alive",
            "Cookie:ttwid=1%7CxFxVdAmTYIeW_qLHss8eWb8EXB_gwQb7rxjf8rKVVAA%7C1723080282%7Cc7a5aaf9685a10f18e731558aef0afe9909db67a44731943c61338a1a5fe9af2; UIFID_TEMP=973a3fd64dcc46a3490fd9b60d4a8e663b34df4ccc4bbcf97643172fb712d8b0d491cf34a443d6a4fbe934bc69004bdb3e9df47e1b123c663c23737c005b25b1061efcc1f9107fba3dda20da588d86f7; s_v_web_id=verify_lzkliiha_AzfTb6Hq_l0Gu_4cmH_BKJ3_UKBu1uFQNX0N; fpk1=U2FsdGVkX1892/Wewm2kl6QVgTdlTHWGz6t8W+ZOkA69Jv4vWXwBpVX3JqwPDviosbcL5SPo+W9LLr6zTnW28g==; fpk2=362d7fe3d8b2581bffa359f0eeda7106; xgplayer_user_id=157989025067; passport_csrf_token=6c5a012a65df3d7aaf5c7b436eb54d37; passport_csrf_token_default=6c5a012a65df3d7aaf5c7b436eb54d37; bd_ticket_guard_client_web_domain=2; UIFID=973a3fd64dcc46a3490fd9b60d4a8e663b34df4ccc4bbcf97643172fb712d8b07d4f8b046eeb4ed33f08610a69a116e514de9239ca9246f41b28e699eff8491ac7da6bffadba9601fda08c85eee06c4b441f1ad1438af03aa4caa6259f8e0a08253758d130879bb691eb4f6dfe163f181960b92bdcf868a85490dba916734044ffa8b0a1c4f77a2b38dde92e74ad508c534e8e6e7cebea21ef1a920a422007f0; __live_version__=%221.1.2.2590%22; live_use_vvc=%22false%22; d_ticket=3a5d57736db2b89e74b7c55f919b6325c2f65; passport_assist_user=CjxFfSP1EneyXAod06kB69vqPJpl3SNii_9cJAMCfuTkFlLzrqNyf-WIDn8OhPlc_oGMjU7--BYe43Dv_FIaSgo8lSWF9RA1QD2IUn-_a6ynaBO9546LgQkxmZJ9znLbApt2bmxLmo4rSJwu4L8AWyB_XpelGY8iIn_JTSMREKaW2Q0Yia_WVCABIgEDDoOUrQ%3D%3D; n_mh=Gi-y0Kudo-jhDK-HkZtaRYg-sabfJtqDw2U9-1uyN0o; sso_uid_tt=d6f7450166abdd40e4330ddcc5325fd1; sso_uid_tt_ss=d6f7450166abdd40e4330ddcc5325fd1; toutiao_sso_user=1ade3a29f87d2b6c8e53029e6b443a32; toutiao_sso_user_ss=1ade3a29f87d2b6c8e53029e6b443a32; sid_ucp_sso_v1=1.0.0-KGMwOGU3YzZiZGI4M2FhMDUzM2Q3MTU3OTI4MmJlMDVmMzA3M2FkODIKHwiDmv_olwIQz9LmtQYY7zEgDDCy14vQBTgGQPQHSAYaAmxxIiAxYWRlM2EyOWY4N2QyYjZjOGU1MzAyOWU2YjQ0M2EzMg; ssid_ucp_sso_v1=1.0.0-KGMwOGU3YzZiZGI4M2FhMDUzM2Q3MTU3OTI4MmJlMDVmMzA3M2FkODIKHwiDmv_olwIQz9LmtQYY7zEgDDCy14vQBTgGQPQHSAYaAmxxIiAxYWRlM2EyOWY4N2QyYjZjOGU1MzAyOWU2YjQ0M2EzMg; passport_auth_status=a1a5b668aa86b1ae49b63c7ee6c68440%2C; passport_auth_status_ss=a1a5b668aa86b1ae49b63c7ee6c68440%2C; uid_tt=ed6dc20f2b674be6d987903a9881f14f; uid_tt_ss=ed6dc20f2b674be6d987903a9881f14f; sid_tt=9cacdef667e779ab2ae3ed95e53a7575; sessionid=9cacdef667e779ab2ae3ed95e53a7575; sessionid_ss=9cacdef667e779ab2ae3ed95e53a7575; is_staff_user=false; _bd_ticket_crypt_doamin=2; _bd_ticket_crypt_cookie=d778a181c6d1023662032eabd8b418ef; __security_server_data_status=1; sid_guard=9cacdef667e779ab2ae3ed95e53a7575%7C1723443540%7C5183998%7CFri%2C+11-Oct-2024+06%3A18%3A58+GMT; sid_ucp_v1=1.0.0-KGFhZTE3MWEzNjVlOGU2OTRiMjYzMzM0Mjg5MzRmN2Y3Y2Y2MzdiYjAKGQiDmv_olwIQ1NLmtQYY7zEgDDgGQPQHSAQaAmxmIiA5Y2FjZGVmNjY3ZTc3OWFiMmFlM2VkOTVlNTNhNzU3NQ; ssid_ucp_v1=1.0.0-KGFhZTE3MWEzNjVlOGU2OTRiMjYzMzM0Mjg5MzRmN2Y3Y2Y2MzdiYjAKGQiDmv_olwIQ1NLmtQYY7zEgDDgGQPQHSAQaAmxmIiA5Y2FjZGVmNjY3ZTc3OWFiMmFlM2VkOTVlNTNhNzU3NQ; store-region=cn-bj; store-region-src=uid; hevc_supported=true; SelfTabRedDotControl=%5B%5D; publish_badge_show_info=%220%2C0%2C0%2C1724851866160%22; _tea_utm_cache_1243=undefined; MONITOR_WEB_ID=0942e354-28c0-4058-9e8d-efbaf3e83d32; my_rd=2; xgplayer_device_id=57310421561; h265ErrorNum=-1; dy_swidth=1920; dy_sheight=1080; pwa2=%220%7C0%7C3%7C0%22; download_guide=%223%2F20240903%2F1%22; WallpaperGuide=%7B%22showTime%22%3A1725341575757%2C%22closeTime%22%3A0%2C%22showCount%22%3A1%2C%22cursor1%22%3A28%2C%22cursor2%22%3A3%7D; __ac_nonce=066d7f1ba00bd1f893aff; __ac_signature=_02B4Z6wo00f01zzH7TAAAIDC4L5yhgqgr.c85-mAAKnwad; douyin.com; device_web_cpu_core=12; device_web_memory_size=8; architecture=amd64; csrf_session_id=a88b9ee0badc44b0042304014b35a572; strategyABtestKey=%221725428158.63%22; stream_player_status_params=%22%7B%5C%22is_auto_play%5C%22%3A0%2C%5C%22is_full_screen%5C%22%3A0%2C%5C%22is_full_webscreen%5C%22%3A0%2C%5C%22is_mute%5C%22%3A1%2C%5C%22is_speed%5C%22%3A1%2C%5C%22is_visible%5C%22%3A1%7D%22; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.5%7D; biz_trace_id=f7f48282; odin_tt=3df65e7358aea186b6caa24e196e14f1dbf428b57e28eac6491feb32b9a1c6271eabaa90d9d948145fc6ef662bc0787e; xg_device_score=7.539387896309158; home_can_add_dy_2_desktop=%220%22; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAANbSMg0p-AoI4HvZJMJgLcrN2BKNyAZ2cg6YuFOIJWTE%2F1725465600000%2F0%2F1725428450305%2F0%22; IsDouyinActive=true; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1920%2C%5C%22screen_height%5C%22%3A1080%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A12%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A100%7D%22; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAANbSMg0p-AoI4HvZJMJgLcrN2BKNyAZ2cg6YuFOIJWTE%2F1725465600000%2F0%2F1725429526444%2F0%22; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCRENaUkVUSjhNZWtnK0pnUnZxRFhoYnRlMzdOVXZNU01qRDBhSkFPaG5WQUN6MHBBU2JMaVZPM1JmRHRoZHgxS3psTThFUUFORElpWjRsSUVLYml3Z3M9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ%3D%3D; passport_fe_beating_status=true"
        ]);
        $result = curl_exec($ch);

        if (curl_errno($ch)) {
            $content = [
                'code' => 500,
                'msg' => "访问出错",
                'api_source' => "官方API网:https://api.pearktrue.cn/"
            ];
            print_json($content);
            exit();
        }
        curl_close($ch);
        return $result;
    }

     private function curl($url, $header = null, $data = null)
    {

        if(!$header){
            $header = ["Cookie:ttwid=1%7CxFxVdAmTYIeW_qLHss8eWb8EXB_gwQb7rxjf8rKVVAA%7C1723080282%7Cc7a5aaf9685a10f18e731558aef0afe9909db67a44731943c61338a1a5fe9af2; UIFID_TEMP=973a3fd64dcc46a3490fd9b60d4a8e663b34df4ccc4bbcf97643172fb712d8b0d491cf34a443d6a4fbe934bc69004bdb3e9df47e1b123c663c23737c005b25b1061efcc1f9107fba3dda20da588d86f7; live_use_vvc=%22false%22; xgplayer_user_id=225065443718; fpk1=U2FsdGVkX19dJ5WcnQBgRV9zPn4XvBBQmit9OCG1fmifYrt/FQAdpQjyDUrMI+uK0MV1sirTiaJawr1Ei0ftRw==; fpk2=362d7fe3d8b2581bffa359f0eeda7106; d_ticket=3a5d57736db2b89e74b7c55f919b6325c2f65; store-region=cn-bj; store-region-src=uid; hevc_supported=true; SelfTabRedDotControl=%5B%5D; my_rd=2; SEARCH_RESULT_LIST_TYPE=%22single%22; passport_csrf_token=91b71805b01f95c6fc43c6fe4df9cc14; passport_csrf_token_default=91b71805b01f95c6fc43c6fe4df9cc14; __security_mc_1_s_sdk_crypt_sdk=c253abbb-4160-97c2; __security_mc_1_s_sdk_cert_key=288a82d1-4fd0-a26b; bd_ticket_guard_client_web_domain=2; __security_mc_1_s_sdk_sign_data_key_login=c58d88db-4448-9178; passport_assist_user=Cjx72BeU7EN3LC11ynTi_ZpvNGDghzh22X6Bn-2sBOa4uGiolX8Fd-saD69diwuiRVj4SqKB0x2Yz0QgqZQaSgo8KoTge4SGY7esCLASJtpQJZxBaE0qtIVRR3pSl2aGy7pX5XtO6JwMOZqKK5uVhS90kKQDvOOa4fI7WAX6EO2c6g0Yia_WVCABIgEDJM5f1Q%3D%3D; n_mh=Gi-y0Kudo-jhDK-HkZtaRYg-sabfJtqDw2U9-1uyN0o; sso_uid_tt=34727fd05c7787fc639424a1f8e21560; sso_uid_tt_ss=34727fd05c7787fc639424a1f8e21560; toutiao_sso_user=897957183084ffac9b1747be8b0396ed; toutiao_sso_user_ss=897957183084ffac9b1747be8b0396ed; sid_ucp_sso_v1=1.0.0-KDA5ZThhMzQ3NTZjMDk1YzA1MjNmYmQzYjU0ZmQwOTAwMzA3NmIzYWEKHwiDmv_olwIQ_bLmvQYY7zEgDDCy14vQBTgFQPsHSAYaAmxxIiA4OTc5NTcxODMwODRmZmFjOWIxNzQ3YmU4YjAzOTZlZA; ssid_ucp_sso_v1=1.0.0-KDA5ZThhMzQ3NTZjMDk1YzA1MjNmYmQzYjU0ZmQwOTAwMzA3NmIzYWEKHwiDmv_olwIQ_bLmvQYY7zEgDDCy14vQBTgFQPsHSAYaAmxxIiA4OTc5NTcxODMwODRmZmFjOWIxNzQ3YmU4YjAzOTZlZA; __security_mc_1_s_sdk_sign_data_key_sso=8a7bda19-46f7-b3e1; login_time=1740216701995; uid_tt=5c32dfc9fa3c845d7a420bc0b371fc1d; uid_tt_ss=5c32dfc9fa3c845d7a420bc0b371fc1d; sid_tt=b0cd71c10a5d6d39a975a43c5a5245d2; sessionid=b0cd71c10a5d6d39a975a43c5a5245d2; sessionid_ss=b0cd71c10a5d6d39a975a43c5a5245d2; is_staff_user=false; _bd_ticket_crypt_doamin=2; _bd_ticket_crypt_cookie=827cd784407291a7559caf33e9907c6e; __security_mc_1_s_sdk_sign_data_key_web_protect=28cbe375-4ff8-b05a; __security_server_data_status=1; __live_version__=%221.1.2.8371%22; __ac_signature=_02B4Z6wo00f01ypp4jwAAIDDHU0mYKUhwqcqSeaAAK0u19; is_dash_user=1; publish_badge_show_info=%220%2C0%2C0%2C1743165826106%22; sid_guard=b0cd71c10a5d6d39a975a43c5a5245d2%7C1743165824%7C5184000%7CTue%2C+27-May-2025+12%3A43%3A44+GMT; sid_ucp_v1=1.0.0-KDk5ZGNhYWUyZTIxYTEyM2VlOTUxNDE2ZWJiYjM0NWIwZTUyZTA0YjQKGQiDmv_olwIQgLOavwYY7zEgDDgFQPsHSAQaAmhsIiBiMGNkNzFjMTBhNWQ2ZDM5YTk3NWE0M2M1YTUyNDVkMg; ssid_ucp_v1=1.0.0-KDk5ZGNhYWUyZTIxYTEyM2VlOTUxNDE2ZWJiYjM0NWIwZTUyZTA0YjQKGQiDmv_olwIQgLOavwYY7zEgDDgFQPsHSAQaAmhsIiBiMGNkNzFjMTBhNWQ2ZDM5YTk3NWE0M2M1YTUyNDVkMg; volume_info=%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.153%7D; download_guide=%223%2F20250328%2F0%22; FOLLOW_NUMBER_YELLOW_POINT_INFO=%22MS4wLjABAAAANbSMg0p-AoI4HvZJMJgLcrN2BKNyAZ2cg6YuFOIJWTE%2F1743177600000%2F0%2F0%2F1743168082259%22; WallpaperGuide=%7B%22showTime%22%3A1743166944206%2C%22closeTime%22%3A0%2C%22showCount%22%3A1%2C%22cursor1%22%3A10%2C%22cursor2%22%3A2%7D; IsDouyinActive=true; stream_recommend_feed_params=%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1920%2C%5C%22screen_height%5C%22%3A1080%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A12%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A0%7D%22; strategyABtestKey=%221743236539.128%22; bd_ticket_guard_client_data=eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCRENaUkVUSjhNZWtnK0pnUnZxRFhoYnRlMzdOVXZNU01qRDBhSkFPaG5WQUN6MHBBU2JMaVZPM1JmRHRoZHgxS3psTThFUUFORElpWjRsSUVLYml3Z3M9IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoyfQ%3D%3D; biz_trace_id=7e0ef242; FOLLOW_LIVE_POINT_INFO=%22MS4wLjABAAAANbSMg0p-AoI4HvZJMJgLcrN2BKNyAZ2cg6YuFOIJWTE%2F1743264000000%2F0%2F1743236539835%2F0%22; home_can_add_dy_2_desktop=%221%22; odin_tt=38fc7d405a615e7ff9807f3625e02a89409192cb4ec855a14067a0ea91725a05065bb36066c5faec2336893cbbd79a75; stream_player_status_params=%22%7B%5C%22is_auto_play%5C%22%3A0%2C%5C%22is_full_screen%5C%22%3A0%2C%5C%22is_full_webscreen%5C%22%3A0%2C%5C%22is_mute%5C%22%3A1%2C%5C%22is_speed%5C%22%3A1%2C%5C%22is_visible%5C%22%3A1%7D%22"];

        }
    	
        $con = curl_init((string)$url);
        curl_setopt($con, CURLOPT_HEADER, false);
        curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($con, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($con, CURLOPT_AUTOREFERER, 1);
        if (isset($header)) {
            curl_setopt($con, CURLOPT_HTTPHEADER, $header);
        }
        if (isset($data)) {
            curl_setopt($con, CURLOPT_POST, true);
            curl_setopt($con, CURLOPT_POSTFIELDS, $data);
        }
        curl_setopt($con, CURLOPT_TIMEOUT, 5000);
        $result = curl_exec($con);
        return $result;
    }

    function location_url($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        $res = curl_exec($ch);
        $final_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
        curl_close($ch);
        return $final_url;
    }


    public function __invoke()
	{
		




		$bloggers = Blogger::query()->where('blogger_url_type','douyin')->get();
		

		foreach($bloggers as $blogger){
			$this->execute($blogger->blogger_url,$blogger->id);
			sleep(2);
		}
		
		

		//Dinglog::text("========== refresh seckill product num end ......");
	}
}
